<template>
    <div class="merchandise-management views-container">
    <div class="wlm-table">
      <div class="wlm-table-hearder-btn">
          <el-form :inline="true" class="demo-form-inline">
          <el-form-item label>
               <el-select v-model="tableFormatData.Details.files.status" placeholder="请选择状态" style="width:200px;">
                 <!-- 1=助力中；2=助力成功；3=已核销；4=已支付；5=待退款；6=已退款 -->
                                <el-option :label="'助力中'" :value="'1'">
                                </el-option>
                                <el-option :label="'助力成功'" :value="'2'">
                                </el-option>
                                <el-option :label="'已核销'" :value="'3'">
                                </el-option>
                                <el-option :label="'已支付'" :value="'4'">
                                </el-option>
                                 <el-option :label="'待退款'" :value="'5'">
                                </el-option>
                                 <el-option :label="'已退款'" :value="'6'">
                                </el-option>
                            </el-select>

            <el-form-item>
                   <el-button type="primary" @click="filesSerch">搜索</el-button>
                                <!-- <el-button type="danger" >发送模板消息</el-button> -->
              <!-- <el-button type="danger" @click="filesEmpty">清除筛选</el-button> -->
              <!-- <el-button type="primary" @click="synchronization" :loading="loading">同步直播间信息</el-button> -->
              <!-- <el-button type="primary" @click="addLiveStudio" :loading="loading">添加直播间</el-button> -->
            </el-form-item>
          </el-form-item>
        </el-form>
      </div>
        <div class="wlm-table-content">
              <!--  -->
             <el-table :ref="tableFormatData.Details.key"
                :data="tableFormatData.Details.tableData"
                @selection-change="handleSelectionChange"
                style="width:100%"
                >
                <el-table-column label="用户名"  >
                    <template slot-scope="scope">
                        <span>{{scope.row.nickname}}</span>
                    </template>
                </el-table-column>
                 <el-table-column label="状态"  >
                    <template slot-scope="scope">
                      <!-- 1=助力中；2=助力成功；3=已核销；4=已支付；5=待退款；6=已退款 -->
                      <el-tag type="warning" v-if="scope.row.status==1">助力中</el-tag>
                      <el-tag type="success" v-if="scope.row.status==2">助力成功</el-tag>
                      <el-tag type="info" v-if="scope.row.status==3">已核销</el-tag>
                      <el-tag type="info" v-if="scope.row.status==4">已支付</el-tag>
                      <el-tag type="info" v-if="scope.row.status==5">待退款</el-tag>
                      <el-tag type="info" v-if="scope.row.status==6">已退款</el-tag>

                      <!-- <span v-if="scope.row.status==1">助力中</span>
                      <span v-if="scope.row.status==2">助力成功</span>
                      <span v-if="scope.row.status==3">已核销</span>
                      <span v-if="scope.row.status==4">已支付</span>
                      <span v-if="scope.row.status==5">待退款</span>
                      <span v-if="scope.row.status==6">已退款</span> -->
                    </template>
                </el-table-column>
                 <el-table-column label="已助力次数"  >
                    <template slot-scope="scope">
                      <span>{{scope.row.power_num}}</span>
                    </template>
                </el-table-column>
                 <el-table-column label="创建时间"  >
                    <template slot-scope="scope">
                        <span>{{scope.row.create_time}}</span>
                    </template>
                </el-table-column>
                 <el-table-column label="核销人"  >
                    <template slot-scope="scope">
                      <span>{{(scope.row.check_uid==0 || scope.row.check_uid=='') ? '-':scope.row.check_uid}}</span>
                    </template>
                </el-table-column>
                 <el-table-column label="核销时间"  >
                    <template slot-scope="scope">
                      <span>{{(scope.row.check_time==0 || scope.row.check_time=='') ? '-':scope.row.check_time}}</span>
                    </template>
                </el-table-column>
                 <el-table-column label="操作"  >
                    <template slot-scope="scope">
                      <div class="operation-group">
                         <!-- <router-link class="wlm-text" tag="a" target="_blank" :to="{path:'/application/treasureHelp',query:{help_id:scope.row.id,uid:scope.row.uid}}">
                              <el-button class="wlm-text" type="text">助力详情</el-button>
                              this.$route.query
                        </router-link> -->
                         <router-link class="wlm-text" tag="span" :to="{path:'/application/treasureHelp', query:{help_id:scope.row.help_id,uid:scope.row.uid}}">
                                        <el-button class="wlm-text" type="text">助力详情</el-button>
                                    </router-link>
                        <div class="btn-line" v-if="scope.row.status==4"></div>
                         <el-button class="wlm-text" type="text" v-if="scope.row.status==4" @click="refund(scope.row.help_id)">退款</el-button>
                         <div class="btn-line"></div>
                         <el-button class="wlm-text" type="text" @click="delbtn(scope.row.help_id)">删除</el-button>
                      </div>
                    </template>
                </el-table-column>
             </el-table>
             <div class="pagination-content flex-row flex-justify-e flex-align-c">
          <el-pagination
            :disabled="!hasTableData"
            @size-change="listPageChange"
            @current-change="listPageChange"
            :current-page.sync="tableFormatData. Details.pagination.page"
            :page-sizes="tableFormatData. Details.pagination.pagesizes"
            :page-size.sync="tableFormatData. Details.pagination.list_rows"
            layout="total, sizes, prev, pager, next, jumper"
            :total="hasTableData?tableFormatData. Details.pagination.total : 0"
          ></el-pagination>
        </div>
        </div>
    </div>
    </div>

</template>
<script>
import{assistDetail,assistUserDetailDelete,assistRefund} from "@/api/application";
import mixins from "@/mixins/mixins";
export default {
     mixins: [mixins.getters("Table")],
     name: "Details",
     data(){
         return{
             tableFormatData: {
        current: "Details",
        Details: {
          key: "Details",
          api: {
            getList: assistDetail,
          },
          tableData: [],
          goods: [],
          files: {
            ids:[],
          },
      
          pagination: {
            status:'',
            page: 1,
            list_rows: 10,
            pagesizes: [10, 20, 50],
            total: 0,
          },
        },
      }, 
         }
     },
     methods:{
         delbtn(help_id){
             this.$confirm('此操作将删除参与人员, 是否继续?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
                }).then(() => {
                     assistUserDetailDelete({help_id:help_id}).then(res=>{
                        if(res.data.code==1){
                            this.$message.success(res.data.msg)
                             this.filesSerch()
                        }
             })
                }).catch(() => {
                this.$message({
                    type: 'info',
                    message: '已取消删除'
                });          
                });
             
         },
         refund(help_id){
             this.$confirm('是否进行退款?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
                }).then(() => {
                     assistRefund({help_id:help_id}).then(res=>{
                        if(res.data.code==1){
                            this.$message.success(res.data.msg)
                             this.filesSerch()
                        }
             })
                }).catch(() => {
                this.$message({
                    type: 'info',
                    message: '已取消删除'
                });          
                });
         }
     },
}
</script>
<style>

</style>